namespace Brjnk.GpxExplorer.Workspace
{
    using System;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Configuration;
    using Brjnk.GpxExplorer.Localization;
    using Brjnk.GpxExplorer.Workspace.BitmapExport;
    using Brjnk.GpxExplorer.Workspace.Searching;
    using Brjnk.Maps;

    /// <summary>
    /// </summary>
    public class Settings : ApplicationSettingsBase, INotifyPropertyChanged
    {
        [UserScopedSetting]
        [SettingsSerializeAs(SettingsSerializeAs.Xml)]
        public ObservableCollection<CustomWebMapSource> CustomMapSources
        {
            get
            {
                if (this["CustomMapSources"] == null) CustomMapSources = new ObservableCollection<CustomWebMapSource>();
                return (ObservableCollection<CustomWebMapSource>)this["CustomMapSources"];
            }
            set { this["CustomMapSources"] = value; }
        }

        [UserScopedSetting]
        [SettingsSerializeAs(SettingsSerializeAs.Xml)]
        public ObservableCollection<CustomExternalApplication> CustomExternalApplications
        {
            get
            {
                if (this["CustomExternalApplications"] == null) CustomExternalApplications = new ObservableCollection<CustomExternalApplication>();
                return (ObservableCollection<CustomExternalApplication>)this["CustomExternalApplications"];
            }
            set { this["CustomExternalApplications"] = value; }
        }

        [UserScopedSetting()]
        public string SelectedMapSource
        {
            get { return (string)this["SelectedMapSource"]; }
            set { this["SelectedMapSource"] = value; }
        }

        [UserScopedSetting()]
        public SearchConfiguration SearchConfiguration
        {
            get
            {
                if (this["SearchConfiguration"] == null) SearchConfiguration = new SearchConfiguration();
                return (SearchConfiguration)this["SearchConfiguration"];
            }
            set { this["SearchConfiguration"] = value; }
        }

        [UserScopedSetting]
        public WaypointStyle WaypointStyle
        {
            get
            {
                if (this["WaypointStyle"] == null) WaypointStyle = new WaypointStyle();
                return (WaypointStyle)this["WaypointStyle"];
            }
            set { this["WaypointStyle"] = value; }
        }

        [UserScopedSetting]
        public RoutePointStyle RoutePointStyle
        {
            get
            {
                if (this["RoutePointStyle"] == null) RoutePointStyle = new RoutePointStyle();
                return (RoutePointStyle)this["RoutePointStyle"];
            }
            set { this["RoutePointStyle"] = value; }
        }

        [UserScopedSetting]
        public TrackPointStyle TrackPointStyle
        {
            get
            {
                if (this["TrackPointStyle"] == null) TrackPointStyle = new TrackPointStyle();
                return (TrackPointStyle)this["TrackPointStyle"];
            }
            set { this["TrackPointStyle"] = value; }
        }

        [UserScopedSetting]
        public SearchPointStyle SearchPointStyle
        {
            get
            {
                if (this["SearchPointStyle"] == null) SearchPointStyle = new SearchPointStyle();
                return (SearchPointStyle)this["SearchPointStyle"];
            }
            set { this["SearchPointStyle"] = value; }
        }

        [UserScopedSetting]
        public ClipboardSettings ClipboardSettings
        {
            get
            {
                if (this["ClipboardSettings"] == null) ClipboardSettings = new ClipboardSettings();
                return (ClipboardSettings)this["ClipboardSettings"];
            }
            set { this["ClipboardSettings"] = value; }
        }

        [UserScopedSetting]
        public IsoLanguageName Language
        {
            get
            {
                if (this["Language"] == null) this["Language"] = new IsoLanguageName();
                return (IsoLanguageName)this["Language"];
            }
            set
            {
                Localization.LocalizationManager.Instance.Language = (value);
                this["Language"] = value;
            }
        }

        [UserScopedSetting]
        public NetworkMode NetworkMode
        {
            get
            {
                if ((object)this["NetworkMode"] == null) NetworkMode = Maps.NetworkMode.Online;
                return (NetworkMode)this["NetworkMode"];
            }
            set
            {
                this["NetworkMode"] = value;
            }
        }

        [UserScopedSetting]
        public bool RoutePointsMultipleSelectionMode
        {
            get
            {
                if ((object)this["RoutePointsMultipleSelectionMode"] == null) RoutePointsMultipleSelectionMode = false;
                return (bool)this["RoutePointsMultipleSelectionMode"];
            }
            set
            {
                this["RoutePointsMultipleSelectionMode"] = value;
            }
        }

        [UserScopedSetting]
        public bool TrackPointsMultipleSelectionMode
        {
            get
            {
                if ((object)this["TrackPointsMultipleSelectionMode"] == null) TrackPointsMultipleSelectionMode = false;
                return (bool)this["TrackPointsMultipleSelectionMode"];
            }
            set
            {
                this["TrackPointsMultipleSelectionMode"] = value;
            }
        }

        [UserScopedSetting]
        public bool AutoCheckForNewVersion
        {
            get
            {
                if ((object)this["AutoCheckForNewVersion"] == null) AutoCheckForNewVersion = true;
                return (bool)this["AutoCheckForNewVersion"];
            }
            set
            {
                this["AutoCheckForNewVersion"] = value;
            }
        }

        [UserScopedSetting]
        public bool AskBeforeCheckForNewVersion
        {
            get
            {
                if ((object)this["AskBeforeCheckForNewVersion"] == null) AskBeforeCheckForNewVersion = true;
                return (bool)this["AskBeforeCheckForNewVersion"];
            }
            set
            {
                this["AskBeforeCheckForNewVersion"] = value;
            }
        }

        [UserScopedSetting]
        public DateTime LastCheckForNewVersion
        {
            get
            {
                if ((object)this["LastCheckForNewVersion"] == null) LastCheckForNewVersion = System.DateTime.Now;
                return (DateTime)this["LastCheckForNewVersion"];
            }
            set
            {
                this["LastCheckForNewVersion"] = value;
            }
        }

        [UserScopedSetting]
        public bool UpdateRequired
        {
            get
            {
                if ((object)this["UpdateRequired"] == null) return true;
                return (bool)this["UpdateRequired"];
            }
            set
            {
                this["UpdateRequired"] = value;
            }
        }

        [UserScopedSetting]
        public bool AllowMoreThanOnePushpin
        {
            get
            {
                if ((object)this["AllowMoreThanOnePushpin"] == null) AllowMoreThanOnePushpin = false;
                return (bool)this["AllowMoreThanOnePushpin"];
            }
            set
            {
                this["AllowMoreThanOnePushpin"] = value;
            }
        }

        [UserScopedSetting]
        public bool SelectPathPointsDuringEditing
        {
            get
            {
                if ((object)this["SelectPathPointsDuringEditing"] == null) SelectPathPointsDuringEditing = true;
                return (bool)this["SelectPathPointsDuringEditing"];
            }
            set
            {
                this["SelectPathPointsDuringEditing"] = value;
            }
        }

        [UserScopedSetting]
        public bool RequireCtrlButtonDuringEditing
        {
            get
            {
                if ((object)this["RequireCtrlButtonDuringEditing"] == null) RequireCtrlButtonDuringEditing = false;
                return (bool)this["RequireCtrlButtonDuringEditing"];
            }
            set
            {
                this["RequireCtrlButtonDuringEditing"] = value;
            }
        }

        [UserScopedSetting]
        public bool EnableDoubleClick
        {
            get
            {
                if ((object)this["EnableDoubleClick"] == null) EnableDoubleClick = true;
                return (bool)this["EnableDoubleClick"];
            }
            set
            {
                this["EnableDoubleClick"] = value;
            }
        }

        #region exportBitmapStyles

        [UserScopedSetting]
        public LabelStyle LabelStyle
        {
            get
            {
                if (this["LabelStyle"] == null) LabelStyle = new LabelStyle();
                return (LabelStyle)this["LabelStyle"];
            }
            private set { this["LabelStyle"] = value; }
        }

        [UserScopedSetting]
        public ArrowStyle ArrowStyle
        {
            get
            {
                if (this["ArrowStyle"] == null) ArrowStyle = new ArrowStyle();
                return (ArrowStyle)this["ArrowStyle"];
            }
            private set { this["ArrowStyle"] = value; }
        }

        [UserScopedSetting]
        public UserLabelStyle UserLabelStyle
        {
            get
            {
                if (this["UserLabelStyle"] == null) UserLabelStyle = new UserLabelStyle();
                return (UserLabelStyle)this["UserLabelStyle"];
            }
            private set { this["UserLabelStyle"] = value; }
        }

        [UserScopedSetting]
        public WaypointLabelStyle WaypointLabelStyle
        {
            get
            {
                if (this["WaypointLabelStyle"] == null) WaypointLabelStyle = new WaypointLabelStyle();
                return (WaypointLabelStyle)this["WaypointLabelStyle"];
            }
            private set { this["WaypointLabelStyle"] = value; }
        }

        [UserScopedSetting]
        public RouteLabelStyle RouteLabelStyle
        {
            get
            {
                if (this["RouteLabelStyle"] == null) RouteLabelStyle = new RouteLabelStyle();
                return (RouteLabelStyle)this["RouteLabelStyle"];
            }
            private set { this["RouteLabelStyle"] = value; }
        }

        [UserScopedSetting]
        public TrackLabelStyle TrackLabelStyle
        {
            get
            {
                if (this["TrackLabelStyle"] == null) TrackLabelStyle = new TrackLabelStyle();
                return (TrackLabelStyle)this["TrackLabelStyle"];
            }
            private set { this["TrackLabelStyle"] = value; }
        }

        #endregion exportBitmapStyles
    }
}